<?php

namespace app\common\model;

use think\Model;
use think\facade\Cache;

class MbtiOrder extends Model
{
    protected $autoWriteTimestamp = true;

    protected $table = 'mbti_order';
    // 定义时间戳字段名
    protected $createTime = 'create_time';
    protected $updateTime = 'update_time';

    /**
     * 添加订单
     * @param $businessOrderNo
     * @param float $amount
     * @param string $pay_type
     * @param int $order_type
     * @param string $channel
     * @return bool
     */
    public function addData($businessOrderNo,$amount = 0.00,$pay_type = '',$order_type = 0,$channel = '')
    {
        $orderNo = createOrderNo(6);
        $this->save([
            'close_time' => date('Y-m-d H:i:s',time() + 10 * 60),
            'business_order_no' => $businessOrderNo,
            'order_no' => $orderNo,
            'amount' => $amount,
            'pay_type' => $pay_type,
            'order_type' => $order_type,
            'channel' => $channel
        ]);
        return $orderNo;
    }
}